package com.fulin.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @Author fulin
 * @Date 2022/9/21 14:50
 **/
public class Num118_杨辉三角 {
    public static void main(String[] args) {
        List<List<Integer>> generate = generate(7);
        generate.forEach(e ->{
            System.out.println(e.toString());
        });
    }

    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> result = new ArrayList<>();
        for(int i = 0; i < numRows; i++){
            List<Integer> list = new ArrayList<>();
            for(int j = 0; j <= i;j++){
                if( j == 0 || j == i){
                    list.add(1);
                }else{
                    List<Integer> father = result.get(i - 1);
                    list.add(father.get(j - 1) + father.get(j));
                }
            }
            result.add(list);
        }
        return result;
    }
}
